from selenium.webdriver.common.by import By


class PageEcshopBackLogin():
    ''' 后台登录'''

    def __init__(self, driver):
        self.driver = driver
        self.url = 'http://192.168.1.241/hdshop/admin/privilege.php?act=login'
        # 元素定位器
        self.loc_login_username = (By.NAME, "username")
        self.loc_login_password = (By.NAME, "password")
        self.loc_login_btn = (By.CLASS_NAME, "btn-a")

    def open(self):
        self.driver.get(self.url)

    def back_login_username(self, username):
        self.driver.find_element(*self.loc_login_username).send_keys(username)

    def back_login_password(self, password):
        self.driver.find_element(*self.loc_login_password).send_keys(password)

    def back_login_btn(self):
        self.driver.find_element(*self.loc_login_btn).click()

    def back_login(self, username, password):
        self.open()
        self.back_login_username(username)
        self.back_login_password(password)
        self.back_login_btn()
